package com.szpx.service.impl;

import com.szpx.entity.HZJ.DrivingSchoolRegistration;
import com.szpx.mapper.DrivingSchoolRegistrationMapper;
import com.szpx.service.DrivingSchoolRegistrationService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;

@Service
public class DrivingSchoolRegistrationServiceImpl implements  DrivingSchoolRegistrationService {

    @Autowired
    private DrivingSchoolRegistrationMapper mapper;

    @Override
    public void saveRegistration(DrivingSchoolRegistration registration) {
        mapper.insert(registration);
    }

    @Override
    public void deleteRegistration(String idCard) {
        mapper.deleteByIdCard(idCard);
    }

    @Override
    public void updateRegistration(DrivingSchoolRegistration registration) {
        mapper.update(registration);
    }

    @Override
    public DrivingSchoolRegistration getRegistrationByIdCard(String idCard) {
        return mapper.selectByIdCard(idCard);
    }

    @Override
    public List<DrivingSchoolRegistration> getAllRegistrations() {
        return mapper.selectAll();
    }

    @Override
    public PageInfo<DrivingSchoolRegistration> getRegistrationsWithPage(int pageNum, int pageSize,Map<String, Object> params) {
        PageHelper.startPage(pageNum, pageSize);
        List<DrivingSchoolRegistration> list = mapper.selectByConditions(params);
        return new PageInfo<>(list);
    }

    @Override
    public List<DrivingSchoolRegistration> getRegistrationsByConditions(Map<String, Object> params) {
        return mapper.selectByConditions(params);
    }
}
